﻿using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Se obtienen todos los registros de una tabla determinada
/// </summary>

namespace consultasSql.consultasVarias
{
    public class CObtenerTodos : CDarDataSet
    {
        public DataSet obtenerTodos(string tabla)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM " + tabla;

            try
            {
                return darDataSet(command);
            }
            catch
            {
            }
            return null;
        }

        public DataSet obtenerTodosPorFK(string tabla, string columnFK, string valorFK)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM " + tabla + " WHERE " + columnFK + " = " + valorFK;

            try
            {
                return darDataSet(command);
            }
            catch
            {
            }
            return null;
        }
    }
}